//
//  KPKeyBoardView.swift
//  keyBordViewPiker
//
//  Created by Mac on 2019/8/14.
//  Copyright © 2019 Mac. All rights reserved.
//

import Foundation
import UIKit
class KPKeyBoardView:UIView,NibLoadable{
    
    @IBOutlet weak var listView: UITableView!
    var selectBankName:((_ str:String)->Void)?
    var soureceData:[String] = ["中国银行","中国农业银行","中国建设银行","交通银行","招商银行","中国民生银行","兴业银行","上海浦东发展银行","上海浦东发展银行","广东发展银行","中信银行","中国光大银行","中国邮政储蓄银行","平安银行","北京银行","上海银行","华夏银行","中国工商银行","四川天府银行","浙商银行","包商银行","中国银联"]
}
extension KPKeyBoardView:UITableViewDataSource,UITableViewDelegate{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.soureceData.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell  = tableView.dequeueReusableCell(withIdentifier: "BankSelectListCellID") as! BankSelectListCell
        cell.label?.text = self.soureceData[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        debugPrint("A",self.soureceData[indexPath.row])
        if self.selectBankName != nil {
            self.selectBankName!(self.soureceData[indexPath.row])
        }
        NotificationCenter.default.post(.init(name:NSNotification.Name(rawValue:"SelectBankNameNoti"), object: self, userInfo: ["SelectBankNameValue":self.soureceData[indexPath.row]]))
    }
    
}
